<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html lang="zh-cn">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta http-equiv="pragma" content="no-cache">  
		<meta http-equiv="cache-control" content="no-cache">  
		<meta http-equiv="expires" content="0">  
		<title>修改密码</title>
		<link href="${webroot }/static/plugins/bootstrap-3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
		<!--时间插件-->
		<link rel="stylesheet" href="${webroot }/static/css/bootstrap-datetimepicker.min.css">
		<!--重置文件-->
		<link rel="stylesheet" href="${webroot }/static/plugins/inputFile/css/style.css" />
		<link rel="stylesheet" href="${webroot }/static/plugins/inputFile/css/ssi-uploader.min.css">
		<link rel="stylesheet" href="${webroot }/static/plugins/icheck/custom.css">
		<link rel="stylesheet" href="${webroot }/static/plugins/icheck/skins/all.css">
		<link rel="stylesheet" href="${webroot }/static/css/reset.css">
		<link rel="stylesheet" href="${webroot }/static/css/merchantGrant.css">
		<jsp:include page="../common/common.jsp"/>
		<style type="text/css">
    	.help-block{
        	float: left;
        	padding-left: 160px;
        }
        .form-group{
        	width:100%!important;
        }
        .has-feedback{
        	width: 480px;
        }
    </style>
	</head>
	<body>
		<section class="content">
			<ol class="breadcrumb">
				<li>管理员管理</li>
				<li class="active">修改密码</li>
			</ol>
			<article id="defaultForm"  class="searchsForm clearfix form-horizontal">
				<form id="updateUserPasswordForm" method="post" class="form-horizontal">
					<div class="form-group clearfix">
						<div class="col-lg-6 col-md-6">
	                	</div>
						<div class="col-lg-6 col-md-6">
							<a href="javascript:;" id="subButton" class="btn btn-primary w-50 fr" style="margin-left: 10px; margin-right: 10px;" onclick="updateUserPassword('updateUserPasswordForm')">提交</a>
							<a style="color: #fff;" href="javascript:history.go(-1);"><input  type="text" id="backButton" value="返回上一级" class="btn btn-primary w-50 fr" style="margin-left: 10px;width: 98px !important; margin-right: 10px;"></a>
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">当前登录名<font style="color: red;"> *</font></label>
						<div class="fl w-300">
							<input type="text" name="loginName" value="${param.loginName }" readonly id="loginName" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">新密码<font style="color: red;"> *</font></label>
						<div class="fl w-300">
							<input type="password" name="password" id="password" value="" class="form-control" />
						</div>
					</div>
					<input type="hidden" name="userId" value="${param.userId }">
				</form>
			</article>
		</section>
<script type="text/javascript">
	function updateUserPassword(formId){
		var bootstrapValidatorData = $("#" + formId).data('bootstrapValidator');
	    if (bootstrapValidatorData) {
	    	//修复记忆的组件不验证
	    	bootstrapValidatorData.validate();
	        if (!bootstrapValidatorData.isValid()) {
	            return false;
	        }
	    }
	    $.confirm({
			title: false,
			content: '确认修改密码吗？',
			type:'green',
			autoClose: 'cancle|3000',
			backgroundDismiss: true,
			buttons: {
				ok: {
					btnClass: 'waves-effect waves-button',
					text: '确定',
					action: function(){
						$.ajax({
					        type: "POST",
					        dataType: "json",
					        url: webroot+"/admin/system/updateUserPassword",
					        data: $("#" + formId).serialize(),
					        success:function(data){
					        	checkResponseData(data,"1",webroot + "/admin/page/system/userList");
					        },
					        error:function(){
					            $.alert({type:'red',title:"错误", content:"请求修改管理员密码接口错误，请查找原因！"});
					        }
					    });
					}
				},
				cancle: {
		            text: '取消',
		            btnClass: 'btn-primary',
		            action: function(){
		            	
		            }
		        }
			}
		});
	}
	//用户表单验证规则
	$('#updateUserPasswordForm').bootstrapValidator({
        feedbackIcons: {/*输入框不同状态，显示图片的样式*/
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {/*验证*/
     	   loginName: {
                validators: {
                	notEmpty: {/*非空提示*/
                        message: '登陆名不能为空'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '请输入字母和数字_ . '
                    },
                    stringLength: {/*长度提示*/
                        min: 3,
                        max: 20,
                        message: '登陆名长度必须在3到20之间'
                    }/*最后一个没有逗号*/
                }
            },
            password: {
                message:'登录密码无效',
                validators: {
                    notEmpty: {
                        message: '登录密码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: '登录密码长度必须在6到30之间'
                    },
                    different: {//不能和用户名相同
                        field: 'loginName',//需要进行比较的input name值
                        message: '不能和登录名相同'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '登录密码只能输入字母和数字_ . '
                    }
                }
            }
        }
    });
</script>
	</body>
</html>
